import { Effect, ImmerReducer, Reducer, Subscription } from 'umi';
import { getvipList } from '@/services';
import { vipList } from '@/types'

export interface vipPageModelState {
  vipDataList: vipList[],
  order: any
}

export interface vipPageType {
  namespace: 'vipData';
  state: vipPageModelState;
  effects: {
    getvipList: Effect;
  };
  reducers: {
    save: Reducer<vipPageModelState>;
  };
}

const vipData: vipPageType = {
  namespace: 'vipData',
  state: {
    vipDataList: [],
    order: {}
  },
  effects: {
    *getvipList({ payload }, { call, put }) {
      let result = yield getvipList(payload);
      console.log(result, '会员');

      if (result) {
        yield put({
          type: 'save',
          payload: {
            vipDataList: result.records,
            order: result
          }
        })
      }
    },
  },
  reducers: {
    save(state, action) {
      return {
        ...state,
        ...action.payload,
      };
    },

  },

};

export default vipData;